package com.shop.controller;

import com.shop.service.DtsSearchHistoryService;
import com.shop.service.DtsUserService;
import com.shop.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AdminHistoryController
 * @Author xiao宋
 * @Date 15:19  2022/10/22
 * @Version 1.0
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/admin/history")
public class AdminHistoryController {
    @Autowired
    DtsSearchHistoryService historyService;

    @GetMapping("/list")
    public Object history(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit,
            @RequestParam(value = "sort", required = false, defaultValue = "add_time") String sort,
            @RequestParam(value = "order", required = false, defaultValue = "desc") String order,
            Integer userId, String keyword
    ) {
        Map<String, Object> data=historyService.findByPage(page, limit, sort, order, userId, keyword);
        return ResponseUtil.ok(data);
    }
}
